package structs

import "math"

// Shape is the interface of all shapes
type Shape interface {
	Area() float64
}

// Rectangle is a struct to describe a rectange.
type Rectangle struct {
	Width  float64
	Height float64
}

// Area is the area of this rectangle
func (r Rectangle) Area() float64 {
	return r.Height * r.Width
}

// Circle is a circle
type Circle struct {
	Radius float64
}

// Area is the area of this circle
func (r Circle) Area() float64 {
	return math.Pi * r.Radius * r.Radius
}

// Triangle is a triangle
type Triangle struct {
	Base   float64
	Height float64
}

// Area is calcualte the area of a triangle
func (t Triangle) Area() float64 {
	return 0.5 * t.Base * t.Height
}

// Perimeter calculate the perimeter of given with and height for a rectange.
func Perimeter(rectangle Rectangle) float64 {
	return 2 * (rectangle.Width + rectangle.Height)
}

// Area calculate the area
func Area(rectangle Rectangle) float64 {
	return rectangle.Width * rectangle.Height
}
